Namespace - LJCDataAccess
Parameters
sql - The SQL command text.
Returns
A reference to the
DbDataReader
object.
Syntax
C# |
public DbDataReader GetDataReader(String sql)
|
Executes a Select statement and retrieves the
DbDataReader
object.
(E)
Remarks
It is the calling programs responsibility to close the connection
when done.
Example
C# |
private static void GetDataReader(DataAccess dataAccess)
{
DbDataReader dbDataReader = null;
string sql = "select * from TableName";
try
{
using (dbDataReader = dataAccess.GetDataReader(sql))
{
while (dbDataReader.Read())
{
for int index = 0; index < dbDataReader.FieldCount; index++)
{
string value = dbDataReader[index].ToString();
}
}
}
}
finally
{
dataAccess.CloseConnection();
}
}
|
Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.